/**
* 左边菜单
*/ 
<template>
  <el-menu default-active="2" :collapse="collapsed" collapse-transition router :default-active="$route.path" unique-opened class="el-menu-vertical-demo" background-color="#334157" text-color="#fff" active-text-color="#ffd04b">
    <div class="logobox">
      <img class="logoimg" src="../assets/img/logo.png" alt="">
    </div>
    <el-submenu v-for="menu in allmenu" :key="menu.menuid" :index="menu.menuname">
      <template slot="title">
        <i class="iconfont" :class="menu.icon"></i>
        <span>{{menu.menuname}}</span>
      </template>
      <el-menu-item-group>
        <el-menu-item v-for="chmenu in menu.menus" :index="'/'+chmenu.url" :key="chmenu.menuid">
          <i class="iconfont" :class="chmenu.icon"></i>
          <span>{{chmenu.menuname}}</span>
        </el-menu-item>
      </el-menu-item-group>
    </el-submenu>
  </el-menu>
</template>
<script>
import { menu } from '../api/userMG'
export default {
  name: 'leftnav',
  data() {
    return {
      collapsed: false,
      allmenu: []
    }
  },
  // 创建完毕状态(里面是操作)
  created() {
    // 获取图形验证码
    let res = {
      success: true,
      data: [
        //综合数据
        {
          menuid: 1,
          icon: 'li-icon-xiangmuguanli',
          menuname: '综合数据',
          hasThird: null,
          url: null,
          menus: [
            {
              menuid: 2,
              icon: 'icon-cat-skuQuery',
              menuname: '首页',
              hasThird: 'N',
              url: 'goods/Goods',
              menus: null
            },
            {
              menuid: 3,
              icon: 'icon-cat-skuQuery',
              menuname: '看板',
              hasThird: 'N',
              url: 'goods/panel',
              menus: null
            }
          ]
        },
        //设备管理
        {
          menuid: 33,
          icon: 'li-icon-dingdanguanli',
          menuname: '设备管理',
          hasThird: null,
          url: null,
          menus: [
            {
              menuid: 31,
              icon: 'icon-order-manage',
              menuname: '设备管理',
              hasThird: 'N',
              url: 'device/Equipment',
              menus: null
            },
            {
              menuid: 35,
              icon: 'icon-order-manage',
              menuname: '设备套餐',
              hasThird: 'N',
              url: 'device/Combo',
              menus: null
            },
            {
              menuid: 36,
              icon: 'icon-order-manage',
              menuname: '设备类型管理',
              hasThird: 'N',
              url: 'device/DeviceType',
              menus: null
            },
            {
              menuid: 34,
              icon: 'icon-order-manage',
              menuname: '设备入库',
              hasThird: 'N',
              url: 'device/Warehousing',
              menus: null
            },
            {
              menuid: 37,
              icon: 'icon-order-manage',
              menuname: '设备分发',
              hasThird: 'N',
              url: 'device/Distribute',
              menus: null
            },
            {
              menuid: 38,
              icon: 'icon-order-manage',
              menuname: '设备充值',
              hasThird: 'N',
              url: 'device/Recharge',
              menus: null
            },
            {
              menuid: 39,
              icon: 'icon-order-manage',
              menuname: '设备流量',
              hasThird: 'N',
              url: 'device/Flow',
              menus: null
            },
            {
              menuid: 40,
              icon: 'icon-order-manage',
              menuname: '流量详单',
              hasThird: 'N',
              url: 'device/Bill',
              menus: null
            },
          ]
        },
        //支付管理
        {
          menuid: 71,
          icon: 'li-icon-xitongguanli',
          menuname: '支付管理',
          hasThird: null,
          url: null,
          menus: [
            {
              menuid: 72,
              icon: 'icon-cus-manage',
              menuname: '订单管理',
              hasThird: 'N',
              url: 'pay/orders',
              menus: null
            },
            {
              menuid: 174,
              icon: 'icon-cms-manage',
              menuname: '退费单管理',
              hasThird: 'N',
              url: 'pay/refund',
              menus: null
            },
            {
              menuid: 73,
              icon: 'icon-news-manage',
              menuname: '微信退费管理',
              hasThird: 'N',
              url: 'pay/WXrefund',
              menus: null
            },
            {
              menuid: 74,
              icon: 'icon-cs-manage',
              menuname: '优惠券管理',
              hasThird: 'N',
              url: 'pay/Coupons',
              menus: null
            },
            {
              menuid: 75,
              icon: 'icon-promotion-manage',
              menuname: '优惠券发放记录',
              hasThird: 'N',
              url: 'pay/CouponRecords',
              menus: null
            },
            {
              menuid: 76,
              icon: 'icon-cms-manage',
              menuname: '充值卡管理',
              hasThird: 'N',
              url: 'pay/RechargeCard',
              menus: null
            },
            {
              menuid: 77,
              icon: 'icon-promotion-manage',
              menuname: '余额充值订单',
              hasThird: 'N',
              url: 'pay/BalanceRecharge',
              menus: null
            },
            {
              menuid: 78,
              icon: 'icon-promotion-manage',
              menuname: '余额充值退费',
              hasThird: 'N',
              url: 'pay/BalanceRefund',
              menus: null
            },
          ]
        },
        //售后管理
        {
          menuid: 128,
          icon: 'li-icon-shangchengxitongtubiaozitihuayuanwenjian91',
          menuname: '售后管理',
          hasThird: null,
          url: null,
          menus: [
            {
              menuid: 129,
              icon: 'icon-provider-manage',
              menuname: '设备售后',
              hasThird: 'N',
              url: 'afterSales/deviceAfterSales',
              menus: null
            },
            {
              menuid: 175,
              icon: 'icon-provider-manage',
              menuname: '资费转移',
              hasThird: 'N',
              url: 'afterSales/TariffTransfer',
              menus: null
            },
            {
              menuid: 176,
              icon: 'icon-provider-manage',
              menuname: '售后投诉',
              hasThird: 'N',
              url: 'afterSales/complaints',
              menus: null
            }
          ]
        },
        //成本管理
        {
          menuid: 1000,
          icon: 'li-icon-shangchengxitongtubiaozitihuayuanwenjian91',
          menuname: '成本管理',
          hasThird: null,
          url: null,
          menus: [
            {
              menuid: 1001,
              icon: 'icon-provider-manage',
              menuname: '限速策略',
              hasThird: 'N',
              url: 'CostMana/tactics',
              menus: null
            },
             {
              menuid: 1002,
              icon: 'icon-provider-manage',
              menuname: '限速记录',
              hasThird: 'N',
              url: 'CostManag/Recording',
              menus: null
            }
          ]
        },
        //商户管理
        {
          menuid: 200,
          icon: 'li-icon-shangchengxitongtubiaozitihuayuanwenjian91',
          menuname: '商户管理',
          hasThird: null,
          url: null,
          menus: [
            {
              menuid: 201,
              icon: 'icon-provider-manage',
              menuname: '商户管理',
              hasThird: 'N',
              url: 'Businesses/Businesses',
              menus: null
            },
          ]
        },
        //调度管理
        {
          menuid: 300,
          icon: 'li-icon-shangchengxitongtubiaozitihuayuanwenjian91',
          menuname: '调度管理',
          hasThird: null,
          url: null,
          menus: [
            {
              menuid: 301,
              icon: 'icon-provider-manage',
              menuname: '卡组管理',
              hasThird: 'N',
              url: 'dispatch/CardSet',
              menus: null
            },
            {
              menuid: 302,
              icon: 'icon-provider-manage',
              menuname: '设备组管理',
              hasThird: 'N',
              url: 'dispatch/DeviceGroups',
              menus: null
            },
            {
              menuid: 303,
              icon: 'icon-provider-manage',
              menuname: '策略配置',
              hasThird: 'N',
              url: 'dispatch/strategy',
              menus: null
            },
            {
              menuid: 304,
              icon: 'icon-provider-manage',
              menuname: '调度日志',
              hasThird: 'N',
              url: 'dispatch/log',
              menus: null
            },
            {
              menuid: 305,
              icon: 'icon-provider-manage',
              menuname: '调度状态',
              hasThird: 'N',
              url: 'dispatch/state',
              menus: null
            },
          ]
        },
        //SIM卡管理
        {
          menuid: 400,
          icon: 'li-icon-shangchengxitongtubiaozitihuayuanwenjian91',
          menuname: 'SIM卡管理',
          hasThird: null,
          url: null,
          menus: [
            {
              menuid: 401,
              icon: 'icon-provider-manage',
              menuname: 'sim卡管理',
              hasThird: 'N',
              url: 'SimCard/manage',
              menus: null
            },
            {
              menuid: 402,
              icon: 'icon-provider-manage',
              menuname: 'sim卡入库',
              hasThird: 'N',
              url: 'SimCard/stockroom',
              menus: null
            },
            {
              menuid: 403,
              icon: 'icon-provider-manage',
              menuname: 'sim卡状态管理',
              hasThird: 'N',
              url: 'SimCard/StateManag',
              menus: null
            },
            {
              menuid: 404,
              icon: 'icon-provider-manage',
              menuname: 'sim卡查询',
              hasThird: 'N',
              url: 'SimCard/enquiries',
              menus: null
            },
          ]
        },
        //套餐管理
        {
          menuid: 500,
          icon: 'li-icon-shangchengxitongtubiaozitihuayuanwenjian91',
          menuname: '套餐管理',
          hasThird: null,
          url: null,
          menus: [
            {
              menuid: 501,
              icon: 'icon-provider-manage',
              menuname: '运营商套餐管理',
              hasThird: 'N',
              url: 'comboManage/Operators',
              menus: null
            },
            {
              menuid: 502,
              icon: 'icon-provider-manage',
              menuname: '用户套餐管理',
              hasThird: 'N',
              url: 'comboManage/user',
              menus: null
            },
            {
              menuid: 503,
              icon: 'icon-provider-manage',
              menuname: '套餐分组',
              hasThird: 'N',
              url: 'comboManage/grouping',
              menus: null
            },
          ]
        },
        //系统管理
        {
          menuid: 600,
          icon: 'li-icon-shangchengxitongtubiaozitihuayuanwenjian91',
          menuname: '系统管理',
          hasThird: null,
          url: null,
          menus: [
            {
              menuid: 601,
              icon: 'icon-provider-manage',
              menuname: '账号管理',
              hasThird: 'N',
              url: 'system/Account',
              menus: null
            },
          ]
        },
        //公众号管理
        {
          menuid: 700,
          icon: 'li-icon-shangchengxitongtubiaozitihuayuanwenjian91',
          menuname: '公众号管理',
          hasThird: null,
          url: null,
          menus: [
            {
              menuid: 701,
              icon: 'icon-provider-manage',
              menuname: '公众号管理',
              hasThird: 'N',
              url: 'OfficialAccount/manage',
              menus: null
            },
            {
              menuid: 702,
              icon: 'icon-provider-manage',
              menuname: '用户标签',
              hasThird: 'N',
              url: 'OfficialAccount/UserLabel',
              menus: null
            },
            {
              menuid: 703,
              icon: 'icon-provider-manage',
              menuname: '微信活动',
              hasThird: 'N',
              url: 'OfficialAccount/activity',
              menus: null
            },
            {
              menuid: 704,
              icon: 'icon-provider-manage',
              menuname: 'app图片',
              hasThird: 'N',
              url: 'OfficialAccount/AppImage',
              menus: null
            },
            {
              menuid: 705,
              icon: 'icon-provider-manage',
              menuname: 'app消息',
              hasThird: 'N',
              url: 'OfficialAccount/AppMessage',
              menus: null
            },
          ]
        },
      ],
      msg: 'success'
    }
          this.allmenu = res.data
    
    // menu(localStorage.getItem('logintoken'))
    //   .then(res => {
    //     console.log(JSON.stringify(res))
    //     if (res.success) {
    //       this.allmenu = res.data
    //     } else {
    //       this.$message.error(res.msg)
    //       return false
    //     }
    //   })
    //   .catch(err => {
    //     this.$message.error('菜单加载失败，请稍后再试！')
    //   })
    // 监听
    this.$root.Bus.$on('toggle', value => {
      this.collapsed = !value
    })
  }
}
</script>
<style>
.el-menu-vertical-demo:not(.el-menu--collapse) {
  width: 240px;
  min-height: 400px;
}
.el-menu-vertical-demo:not(.el-menu--collapse) {
  border: none;
  text-align: left;
}
.el-menu-item-group__title {
  padding: 0px;
}
.el-menu-bg {
  background-color: #1f2d3d !important;
}
.el-menu {
  border: none;
}
.logobox {
  height: 40px;
  line-height: 40px;
  color: #9d9d9d;
  font-size: 20px;
  text-align: center;
  padding: 20px 0px;
}
.logoimg {
  height: 40px;
}
</style>